<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../../lsh/js/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root">
        <h2>你好啊 <span v-text='n'></span></h2>
        <h2>你好啊 <span v-big='n'></span></h2>
        <button type="" @click='n++'>点我加1</button>
        <input type="text" name="" id="" v-fbind="n">
    </div>
</body>
<script>
    Vue.config.productionTip = false
    new Vue({
        el: '#root',
        data: {
            n: 1
        },
        directives: { //big函数什么时候调用，1，当指令跟元素成功绑定时，2，指令所在的模板重新解析时
            big(element, binding) {
                element.innerText = binding.value * 10
            },
            fbind: {
                //1，当指令跟元素成功绑定时
                bind(element, binding) {
                    element.value = binding.value * 10
                },
                //2，指定所在元素插入页面时
                inserted(element, binding) {
                    element.focus()
                },
                //3，指定所在的模板重新解析时
                update(element, binding) {
                    element.value = binding.value * 10
                }
            }
        }
    })
</script>

</html>